package handler

import (
	api "gitee.com/perception-network/block-chain-released/api/protos/blockChain/v1alpha"
	"gitee.com/perception-network/block-chain-released/internal/model"
	tsp "google.golang.org/protobuf/types/known/timestamppb"
)

func BlockChainReleasesToPB(in []*model.Release) []*api.BlockChainReleased {
	out := make([]*api.BlockChainReleased, 0, len(in))
	for _, v := range in {
		out = append(out, BlockChainReleaseToPB(v))
	}
	return out
}

func BlockChainReleaseToPB(in *model.Release) *api.BlockChainReleased {
	out := &api.BlockChainReleased{
		Id:      uint64(in.ID),
		Name:    in.Name,
		Version: in.Version,
	}

	out.CreateTime = tsp.New(in.CreateTime)

	return out
}
